package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class CollectionDemo1 {
    public static void main(String[] args) {
        /*
       //ArrayList实现了List接口，List接口继承了Collection接口
        Collection c1 = new ArrayList();

        //HashSet实现了Set接口,Set接口继承了Collection接口
        Collection c2 = new HashSet();
        */

        Collection c = new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        System.out.println(c);

//        Collection c1 = new HashSet();
//        c1.add("one");
//        c1.add("two");
//       boolean b = c1.add("one");
//        System.out.println(b);
//        System.out.println(c1);

        System.out.println("size:"+c.size());
        System.out.println("是否为空:"+c.isEmpty());
        c.clear();
        System.out.println("集合已清空");
        System.out.println(c);
        System.out.println("size:"+c.size());
        System.out.println("是否为空:"+c.isEmpty());


    }
}
